12. Setting up ball_chaser

Setting up ball_chaser

The second major task in this project is to create the ball_chaser ROS package. Within this package, you'll analyze the image captured by the camera to determine the position of a white ball. Then you’ll drive the robot toward the ball. The nodes in ball_chaser will communicate with the my_robot package by subscribing to the robot camera sensor and publishing to the robot’s wheel joints.

Package Nodes

The ball_chaser package will have two C++ nodes: the drive_bot and process_image

  • drive_bot : This server node will provide a ball_chaser/command_robot service to drive the robot around by controlling its linear x and angular z velocities. The service will publish a message containing the velocities to the wheel joints.
  • process_image : This client node will subscribe to the robot’s camera images and analyze each image to determine the position of the white ball. Once ball position is determined, the client node will request a service to drive the robot either left, right or forward.

Now, follow along with the steps to set up ball_chaser .

Create the ball_chaser Package

1- Navigate to the src directory of your catkin_ws and create the ball_chaser package:

We will be writing nodes in C++. Since we already know in advance that this package will contain C++ source code and messages, let’s create the package with those dependencies:

$ cd /home/workspace/catkin_ws/src/
$ catkin_create_pkg ball_chaser roscpp std_msgs message_generation

2- Next, create an srv and a launch folder, which will further define the structure of your package:

$ cd /home/workspace/catkin_ws/src/ball_chaser/
$ mkdir srv
$ mkdir launch

Remember, srv is the directory where you store service files and launch is the directory where you store launch files. The src directory where you will store C++ programs is created by default.

Build the Package

$ cd /home/workspace/catkin_ws/
$ catkin_make

Now you should be ready to write some code!

Task Description:

Follow these steps to set up the ball_chaser package:

Task List:

Task Feedback:

Great job!